package com.aurora.strategy.impl;

import com.aurora.config.properties.OssConfigProperties;
import com.aurora.service.RedisService;
import com.aurora.strategy.RedisStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("redisStrategyImpl")
public class RedisStrategyImpl implements RedisStrategy {

    @Autowired
    private RedisService redisService;

    @Autowired
    private OssConfigProperties ossConfigProperties;

    @Override
    public void sAddWithOss(String key,String value) {
        String[] split = value.split(ossConfigProperties.getUrl());
        if (split.length > 1) {
            String path = split[1];
            redisService.sAdd(key, path);
        }
    }

    @Override
    public void sRemoveWithOss(String key, String value) {
        String[] split = value.split(ossConfigProperties.getUrl());
        if (split.length > 1) {
            String path = split[1];
            redisService.sRemove(key, path);
        }
    }
}
